//2009/08/18 23:46:57
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class ObjectFall
{
public:
    int howLong(int x, int y, vector <string> obstacles)
    {
        int t = 0;
        for (int cy = y; cy>0; cy--)
            for (int i = 0 ; i < obstacles.size(); i++)
            {
                stringstream s(obstacles[i]);
                int y1, x1, x2;
                s >> y1 >> x1 >> x2;
                if (cy == y1 && x >= x1 && x <= x2)
                {
                    x = x2;
                    t+=5;
                    break;
                }
            }
        return y+t;
    }
};
